package com.servlet.article;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dao.ArticleDAO;
import com.dao.UsersDAO;
import com.entity.Article;
import com.entity.Users;

public class FindAllArticleServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		List<Article> article = null;

		ArticleDAO articleDAO = new ArticleDAO();
		article = articleDAO.findAll();
		request.setAttribute("article", article);
		RequestDispatcher re = request
				.getRequestDispatcher("/background/articlelist.jsp");
		re.forward(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		List<Article> article = null;

		ArticleDAO articleDAO = new ArticleDAO();
		article = articleDAO.findAll();
		request.setAttribute("article", article);
		RequestDispatcher re = request
				.getRequestDispatcher("/background/articlelist.jsp");
		re.forward(request, response);
	}

}
